{include file="common/head"}
<style>
	a {
		text-decoration: none;
	}

	.title {
		font-weight: bold;
	}

	input {
		display: initial !important;
	}


	.row {
		margin: 8px;
	}


</style>
<link rel="stylesheet" href="/static/flatpickr/flatpickr.min.css">
<script src="/static/flatpickr/flatpickr.js"></script>
<title>下单</title>
</head>

<body>
	<div class="container-fluid">
		<!-- <form action="/index.php/order/order_add" method="post"> -->

		<div class="title" style="height:50px;line-height: 50px;padding:10px;" class="row">
			<div class="col-6">
				<h2>广告位租用--下单</h2>
			</div>
			<div class="col text-right">

			</div>
		</div>

		<div class="row">
			<div id="customer_info" class="col-5" style="border:1px solid #ccc;">
				<div class="row">
					<div class="col-3 title">广告位</div>
					<div class="col fs-3">
						<input type="hidden" id="g_id" value="{$ad['id']}" />
						{$ad['name']} {$ad['desc']}
					</div>
				</div>
				<div class="row">
					<div class="col-3 title">价格</div>
					<div class="col">
						<c class="fs-3">{$ad['price']}/天</c>
						<c class="fs-4">{$ad['price_desc']}</c>
					</div>
				</div>

				<div class="row">
					<div class="col-3 title">开始日期</div>
					<div class="col fs-4">
                    	{$sdate}
                    </div>
				</div>
				<div class="row">

					<div class="col-3 title">结束日期</div>
					<div class="col">                    
						<input class="form-control" type="text" value="" id="edate" name="edate"
                        placeholder="结束日期" />
                    </div>
				</div>

				<div class="row">
					<div class="col-3 title">跳转链接</div>
					<div class="col">
						<input type="text" id="link_url" name="link_url" class="form-control" placeholder="跳转链接" />
					</div>
				</div>

				<div class="row">
					<div class="col-3 title">给管理员留言</div>
					<div class="col">
						<input type="text" id="memo" name="memo" class="form-control" placeholder="给管理员留言" />
					</div>
				</div>

				<div style="text-align: center;margin:10px;">
					<button type="button" id="order_submit" class="btn btn-primary ">提交订单</button>

				</div>
			</div>

		</div>

		<!-- </form> -->

		<div id="mask"></div>
	</div>
	<script>
		var goods_list = []
		var current_item = {};

		$(function () {
			flatpickr("#sdate,#edate", {});

			function order_submit() {
				var order = {};
				order.g_id=$("#g_id").val();
				order.link_url=$("#link_url").val();
				order.edate=$("#edate").val();
				order.memo=$("#memo").val();

				if(!order.edate || !order.link_url){
					layer.msg('请填写完整!');
					return;
				}

				console.log(order)

				layer.confirm('是否确定提交订单？', ['确定', '再检查一下'], function () {
					$.post('/order/order_add', order, function (res) {
						if (res.code == 1) {
							layer.open({ 'content': '订单已保存！' });
							setTimeout(function(){
								location.href='/order/index';
							},3000);
						} else {
							layer.open({ content: res.msg });
						}
					})
				}, function () {
					layer.msg('yes!');
				})

			}

			$("#order_submit").on('click', function () {
				return order_submit();
			})

		})

	</script>
</body>

</html>